﻿using System.Web.Mvc;
using Smarly.Web.Areas.Profile.Controllers;
using Smarly.Web.RouteConstraints;

namespace Smarly.Web.Areas.Profile
{
	public class ProfileAreaRegistration : AreaRegistration
	{
		public override string AreaName
		{
			get
			{
				return "Profile";
			}
		}

		public const string Subdomain = "profile";

		public override void RegisterArea(AreaRegistrationContext routes)
		{

			routes.MapRoute(
					"Profile_Default1",
					"wtf",
					new { controller = "Default1", action = "Index", subdomain = Subdomain },
					new { subdomain = new DomainRouteConstraint() },
					new[] { typeof(Default1Controller).Namespace }
			);			
			
			
			#region Ebook

			routes.MapRoute(
					"Profile_Ebook_Download_pdf",
					"ebook/download/{*parts}",
					new { controller = "Ebook", action = "Download", extention = "pdf", subdomain = Subdomain },
					new { extention = new ExtentionRouteConstraint(), subdomain = new DomainRouteConstraint() },
					new[] { typeof(EbookController).Namespace }
			);

			routes.MapRoute(
					"Profile_Ebook_pdf",
					"ebook/{*parts}",
					new { controller = "Ebook", action = "Index", extention = "pdf", subdomain = Subdomain },
					new { extention = new ExtentionRouteConstraint(), subdomain = new DomainRouteConstraint() },
					new[] { typeof(EbookController).Namespace }
			);


			#endregion

			#region Yandex.Money

/*
			routes.MapRoute(
					"Profile_Yandex_ClientToken",
					"payment/yandex/buy/{purchaseId}/{purchaseHashCode}",
					new { controller = "Yandex", action = "Payment" },
					new { },
					new[] { typeof(YandexController).Namespace }
			);
*/

			routes.MapRoute(
					"Profile_Yandex",
//					"payment/yandex/{bookId}/{value}",
					"payment/yandex/{bookId}",
					new { controller = "Yandex", action = "Index" },
					new { },
					new[] { typeof(YandexController).Namespace }
			);
/*
			routes.MapRoute(
					"Profile_Yandex_post",
					"payment/yandex",
					new { controller = "Yandex", action = "Index" },
					new { },
					new[] { typeof(YandexController).Namespace }
			);*/

			#endregion

			#region Account

			routes.MapRoute(
				"Profile_CreateAccount",
				"account/create",
				new { controller = "Account", action = "Create", subdomain = Subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(AccountController).Namespace }
				);

			routes.MapRoute(
				"Profile_RepearAccount",
				"account/repear",
				new { controller = "Account", action = "Repear", subdomain = Subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(AccountController).Namespace }
				);

			routes.MapRoute(
				"Profile_UpdateAccount",
				"account/update/{hashcode}",
				new { controller = "Account", action = "UpdatePassword", hashcode = UrlParameter.Optional, subdomain = Subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(AccountController).Namespace }
				);

			routes.MapRoute(
				"Profile_SignOutAccount",
				"account/logout",
				new { controller = "Account", action = "Logout", subdomain = Subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(AccountController).Namespace }
				);

			routes.MapRoute(
				"Profile_SignInAccount",
				"account",
				new { controller = "Account", action = "Index", subdomain = Subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(AccountController).Namespace }
				);

			routes.MapRoute(
				"Profile_Account_UserInfo",
				"account/{emailsh1}",
				new { controller = "Account", action = "UserInfo", subdomain = Subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(AccountController).Namespace }
				);

			#endregion


			routes.MapRoute(
					"Profile_default",
					"",
					new { controller = "Home", action = "Index", subdomain = Subdomain },
				new { subdomain = new DomainRouteConstraint() },
				new[] { typeof(HomeController).Namespace }
				);
		}
	}
}
